package lhb.spark.clean

import org.apache.spark.sql.SparkSession

object clean {
  def main(args: Array[String]): Unit = {
    val spark = SparkSession.builder().appName("sparkclean").getOrCreate()

    val jdbcdf = spark.read.format("JDBC")
      .option("url", "jdbc:sqlserver://192.168.82.57:1433;DatabaseName=SBJ")
      .option("driver", "com.microsoft.sqlserver.jdbc.SQLServerDriver")
      .option("dbtable", "dbo.FIXALARMS1")
      .option("user", "sa")
      .option("password", "123456QWERTYUIOP&")
      .load()

    val frame = jdbcdf.na.drop(Seq("ALM_TAGNAME"))


      frame.write.format("JDBC")
      .option("url", "jdbc:sqlserver://192.168.82.57:1433;DatabaseName=SBJ")
      .option("driver", "com.microsoft.sqlserver.jdbc.SQLServerDriver")
      .option("dbtable", "dbo.ALARMNONULL")
      .option("user", "sa")
      .option("password", "123456QWERTYUIOP&")
      .option("truncate", "True")
      .mode("overwrite")
      .save()
  }
}
